﻿// See https://aka.ms/new-console-template for more information

using TiaoTiaoCode.AutoUpdate.ClientCore;
using TiaoTiaoCode.AutoUpdate.ClientCore.AutoUpdateEventArgs;
using TiaoTiaoCode.AutoUpdate.Common.Dtos;

var bootstrap = new ClientUpgradeBootstrap();

bootstrap.OnFileAllDownloadCompleted += Bootstrap_OnFileAllDownloadCompleted;
bootstrap.OnFileDownloading += Bootstrap_OnFileDownloading;
bootstrap.OnFileDownloadCompleted += Bootstrap_OnFileDownloadCompleted;
bootstrap.OnFindAllFilesCompleted += Bootstrap_OnFindAllFilesCompleted;

//bootstrap.Config()
//    .SetMainProgramName("Danfoss.Shell.Client.exe");

bootstrap.QuickSimpleConfig();

//.SetUpgradeClientName("TiaoTiaoCode.AutoUpdate.ClientUI.exe")
//.SetUpgradeConfirm(()=>
//{
//    var data = Console.ReadLine();

//    return data == "true";
//});

if (!await bootstrap.HasUpgrade())
{
    Console.WriteLine("无须更新");
    Console.Read();
    return;
}
//bootstrap.HasUpgrade();

bootstrap.Startup();

void Bootstrap_OnFindAllFilesCompleted(List<ProgrameFileDetailView> files)
{
    Console.WriteLine("获取文件完成");
}

void Bootstrap_OnFileDownloadCompleted(FileDownloadCompletedEventArgs args)
{
    Console.WriteLine($"下载完成:{args.FileName}");
}

void Bootstrap_OnFileDownloading(FileDownloadingEventArgs args)
{
    Console.WriteLine($"开始下载:{args.FileName}");
}

void Bootstrap_OnFileAllDownloadCompleted()
{
    Console.WriteLine($"全部下载完成");
}

Console.Read();
